package org.abrysov.android.lombarditems;

import org.abrysov.android.lombarditens.activity.NewItemPanel;
import org.abrysov.android.lombarditens.activity.StockList;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class MainActivity extends Activity {

	public final static String DATABASE_NAME = "LombardDb.db";
	private final static String TAG = "_li_MainActivity.class";
	
	private Button mNewItem = null;
	private Button mStock = null;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        
        mNewItem = (Button)findViewById(R.id.main_new_item);
        mNewItem.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				
				startActivity(new Intent (getApplicationContext(), NewItemPanel.class));
				
			}
		});
        
        mStock = (Button)findViewById(R.id.main_b_stock);
        mStock.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				startActivity(new Intent(getApplicationContext(), StockList.class));
			}
		});
        
//        LombardData data = new LombardData(this);
        
        SQLiteDatabase db = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null);

        db.execSQL("CREATE TABLE IF NOT EXISTS items (id INT, description VARCHAR, cost VARCHAR, serial_num VARCHAR , rating VARCHAR, used INT, info VARCHAR, client_photo_path VARCHAR, item_photo_path VARCHAR, category VARCHAR);");
//        db.execSQL("INSERT INTO items VALUES ('1', 'Video Camera Samsung');");
        
        try {
//            Cursor c = db.rawQuery("SELECT * from items", null);
//            c.moveToFirst();
//            Log.d(TAG, c.getString(c.getColumnIndex("description")));
            db.close();
		} catch (Exception e) {
			e.printStackTrace();
		}
        
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    
}
